package edu.mju.eduStatistics.schedule;

import edu.mju.eduStatistics.service.StatisticsDailyService;
import edu.mju.eduStatistics.utils.DateUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.util.Date;

/**
 * 定时器任务:springboot支持6位 不支持7位
 * @Author: wyp
 * @Date: 2020/11/14 22:22
 */
@Component
public class ScheduledTask {

    @Autowired
    private StatisticsDailyService statisticsDailyService;

    /**
     * 在每天00：30分，把前一天数据进行数据查询添加
     */
    @Scheduled(cron = "0 30 0 * * ? ")
    public void task() {
        statisticsDailyService.registerCount(DateUtil.formatDate(DateUtil.addDays(new Date(), -1)));
    }
}
